package shoot;

import java.awt.image.BufferedImage;
import java.util.Random;

/**
 * 英雄机
 */
public class HeroAirPlane extends FlyingObject {
    private int life;
    private int doubleFire;
    private int speed;
    
    public static BufferedImage images;
    static {
    	images=loadImage("hero.png");
    }
    

    public HeroAirPlane(){
        super(80, 124, 156, 450);
        speed=2;
        life=3;
        doubleFire=20;
    }
    
    @Override
	public BufferedImage getImage() {
		// TODO Auto-generated method stub
		if (isLife()) {
			return images;
		}
		return null;
	}
    
    /**
     * 射击生成子弹
     * @return
     */
    public Bullet[] shoot() {
		//计算子弹的位置
    	int space=this.width/4;
    	if(doubleFire>0) {
    		//生成2排子弹
    		Bullet[] bsBullets=new Bullet[2];
    		bsBullets[0]=new Bullet(this.x + 1 * space, y);
    		bsBullets[1]=new Bullet(this.x + 3 * space, y);
    		doubleFire-=10;
    		return bsBullets;
		}else {
			//单排子弹
			Bullet[] bsBullets=new Bullet[1];
    		bsBullets[0]=new Bullet(this.x + 2 * space, y);
    		return bsBullets;
		}
	}
    
    @Override
    public void step() {
    	// TODO Auto-generated method stub
    	
    }
    
    public void moveTo(int x,int y) {
		this.x=x-this.width/2;
		this.y=y-this.height/2;
	}
    
    
    public void delLife() {
		life--;
	}
    
    public int getLife() {
		return life;
	}
    
    public void addLife() {
		life++;
	}
    
    public int getDoubleFire() {
		return doubleFire;
	}
    
    public void addDoubleFire() {
		doubleFire+=20;
	}
    
    
    public void clearDoubleFire() {
		doubleFire=0;
	}
    
    
    
}
